Skip to content

fix: add husky install fallback - #591

Merged
cameri merged 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/husky-not-found
May 3, 2026
Merged

cameri merged 1 commit into
cameri:mainfrom
Priyanshubhartistm:fix/husky-not-found

Conversation

@Priyanshubhartistm

Copy link
Copy Markdown
Collaborator

Description

I fixed the Husky install path that was causing sh: husky: not found.

The old prepare script ran husky install exit 0. That avoided failing the install, but it still printed the shell
error first when Husky was not installed.

I moved that logic into .husky/install.mjs so Husky is skipped cleanly in production, CI, HUSKY=0, and installs where
the Husky package is not available.

I also updated the Dockerfiles so .husky/install.mjs is copied before npm install runs.

Related Issue

Fixes #328

Motivation and Context

Husky is only needed for local git hooks. It should not make production, CI, or Docker installs look broken when dev
dependencies are missing.

This keeps local hook setup working, but avoids the noisy sh: husky: not found message in environments where Husky
should be skipped.

How Has This Been Tested?

I verified the script syntax:

node --check .husky/install.mjs

I verified the skip paths:

NODE_ENV=production npm run prepare --silent
CI=true npm run prepare --silent
HUSKY=0 npm run prepare --silent
npm_config_omit=dev npm run prepare --silent

All commands completed successfully without printing the Husky error.

I also checked the old behavior still reproduces the original issue:

sh -c 'husky install exit 0'

It prints:

sh: 1: husky: not found

Screenshots (if appropriate):

image

Types of changes

  • Non-functional change (docs, style, minor refactor)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my code changes.
  • I added a changeset, or this is docs-only and I added an empty changeset.
  • All new and existing tests passed.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] sh: husky: not found

3 participants